// src/pages/task/schedule/components/ActionButtons.tsx - 操作按钮组件
import React from 'react';
import { Button, Popconfirm } from 'antd';
import { EditOutlined, DeleteOutlined, PlayCircleOutlined } from '@ant-design/icons';
import { ScheduleItem } from '../types';

interface ActionButtonsProps {
  record: ScheduleItem;
  onRun: (id: number, record: ScheduleItem) => void;
  onEdit: (record: ScheduleItem) => void;
  onDelete: (id: number) => void;
}

const ActionButtons: React.FC<ActionButtonsProps> = ({ record, onRun, onEdit, onDelete }) => {
  return (
    <div style={{ display: 'flex', gap: '8px', justifyContent: 'center' }}>
      <Popconfirm
        title="确认运行"
        description={`确定要运行任务 "${record.name}" 吗？`}
        onConfirm={() => onRun(record.id, record)}
        okText="确认"
        cancelText="取消"
      >
        <Button 
          type="primary" 
          icon={<PlayCircleOutlined />} 
          size="small"
        />
      </Popconfirm>
      <Button 
        type="default" 
        icon={<EditOutlined />} 
        onClick={() => onEdit(record)}
        size="small"
      />
      <Popconfirm
        title="确认删除"
        description={`确定要删除任务 "${record.name}" 吗？`}
        onConfirm={() => onDelete(record.id)}
        okText="确认"
        cancelText="取消"
      >
        <Button 
          type="primary" 
          danger 
          icon={<DeleteOutlined />} 
          size="small"
        />
      </Popconfirm>
    </div>
  );
};

export default ActionButtons;